/*
jQuery ile bir elementin pozisyonlarinin alinmasi
kaynak : http://www.zurb.com/javascripts/plugins/jquery.annotate.js
*/
$.fn.relativeX = function(xPosition) {
	var left = $(this).coordinates().x + ($(this).xOffset(xPosition));
	var width = $(this).parent().width();
	return left / width;
}

$.fn.relativeY = function(yPosition) {
	var top = $(this).coordinates().y + ($(this).yOffset(yPosition));
	var height = $(this).parent().height();
	return top / height;
}

$.fn.relativeWidth = function() {
	return $(this).width() / $(this).parent().width();
}

$.fn.relativeHeight = function() {
	return $(this).height() / $(this).parent().height();
}

$.fn.xOffset = function(xPosition) {
	switch (xPosition) {
		case 'left': return 0; break;
		case 'right': return $(this).width(); break;
		default: return $(this).width() / 2;
	}
};

$.fn.yOffset = function(yPosition) {
	switch (yPosition) {
		case 'top': return 0; break;
		case 'bottom': return $(this).height(); break;
		default: return $(this).height() / 2;
	}
};

$.fn.coordinates = function() {
	return {x: parseInt($(this).css('left').replace('px', '')), y: parseInt($(this).css('top').replace('px', ''))};
};